<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MTB CAT1 Peripheral driver library: SAR2         (Analog to Digital Converter (ADC))</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="IFXCYP_one-line.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">MTB CAT1 Peripheral driver library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__group__sar2.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#groups">API Reference</a>  </div>
  <div class="headertitle">
<div class="title">SAR2 (Analog to Digital Converter (ADC))</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<p>The SAR2 driver provides an API to configure the SAR2 ADC. </p>
<p>The SAR2 has up to 4 ADCs and up to 32 channels for each ADC module. About actual number of supported modules and channels, refer to the technical reference manual (TRM) and device datasheet.</p>
<h1><a class="anchor" id="group_sar2_configuration"></a>
Configuration Considerations</h1>
<p>Typical usage:</p><ul>
<li>Call Cy_SAR2_Init to initialize the ADC module and its channels</li>
<li>Call Cy_SAR2_Channel_SetInterruptMask if you need to use the interrupt. After initializing channel(s) call, trigger a call by the software (calling Cy_SAR2_Channel_SoftwareTrigger) or start a peripheral configured for the HW trigger.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>It is not recommended to set the triggerSelection structure member of the <a class="el" href="structcy__stc__sar2__channel__config__t.html">cy_stc_sar2_channel_config_t</a> to CY_SAR2_TRIGGER_CONTINUOUS if cy_en_sar2_preemption_type_t is set to CY_SAR2_PREEMPTION_ABORT_CANCEL. It may work to the effect that the channel or channel group will not be able to complete without advanced priority tuning. </dd></dl>
<dl class="section user"><dt></dt><dd></dd></dl>
<dl class="section note"><dt>Note</dt><dd>If you use an interrupt for ADC, create an interrupt handler and register it by using the sysint module. In the handler, you can check which interrupt is occurred by Cy_SAR2_Channel_GetInterruptStatusMasked and can get the conversion result by Cy_SAR2_Channel_GetResult. If you do not use the interrupt, you can poll the conversion status by Cy_SAR2_Channel_GetInterruptStatus. For both of polling and interrupt, clear the interrupt flags by Cy_SAR2_Channel_ClearInterrupt after handling data. </dd></dl>
<dl class="section user"><dt></dt><dd></dd></dl>
<dl class="section note"><dt>Note</dt><dd>SAR2 block can operate in Active or Sleep mode only.</dd></dl>
<h2><a class="anchor" id="group_sar2_config"></a>
Configuration Example</h2>
<p>First step would be to configure clock:</p>
<div class="fragment"><div class="line">    <span class="comment">/* Scenario: CLH_HF2 has been configured to output 196 MHz.</span></div><div class="line"><span class="comment">     * Use one of the PeriClk dividers with a divider value of 50 to get a 3.92 Mhz SAR clock. */</span></div><div class="line"></div><div class="line">    <span class="comment">/* Assign divider number 0 of the the 8-bit dividers to the SAR2, block 0. */</span></div><div class="line">    <a class="code" href="group__group__sysclk__clk__peripheral__funcs.html#ga2f480c53ecec720ceed823b2692f1698">Cy_SysClk_PeriphAssignDivider</a>(PCLK_PASS0_CLOCK_SAR0, <a class="code" href="group__group__sysclk__clk__peripheral__enums.html#gga06138349be16d91fd5d00ded2f4592b8ad2299deae6e36a070de5a60368b319ad">CY_SYSCLK_DIV_8_BIT</a>, 0U);</div><div class="line"></div><div class="line">    <span class="comment">/* Disable assigned divider. */</span></div><div class="line">    <a class="code" href="group__group__sysclk__clk__peripheral__funcs.html#ga8754ff2f756d0d82af230600139a2442">Cy_SysClk_PeriPclkDisableDivider</a>((1U &lt;&lt; PERI_PCLK_GR_NUM_Pos), <a class="code" href="group__group__sysclk__clk__peripheral__enums.html#gga06138349be16d91fd5d00ded2f4592b8ad2299deae6e36a070de5a60368b319ad">CY_SYSCLK_DIV_8_BIT</a>, 0U);</div><div class="line"></div><div class="line">    <span class="comment">/* Divide the PeriClk by 50, which is a input value of 49. */</span></div><div class="line">    <a class="code" href="group__group__sysclk__clk__peripheral__funcs.html#ga7d0d4bfdaa3ca5b5f2f50b3d2cdc6d57">Cy_SysClk_PeriPclkSetDivider</a>((1U &lt;&lt; PERI_PCLK_GR_NUM_Pos), <a class="code" href="group__group__sysclk__clk__peripheral__enums.html#gga06138349be16d91fd5d00ded2f4592b8ad2299deae6e36a070de5a60368b319ad">CY_SYSCLK_DIV_8_BIT</a>, 0U, 49U);</div><div class="line"></div><div class="line">    <span class="comment">/* Enable the divider. */</span></div><div class="line">    <a class="code" href="group__group__sysclk__clk__peripheral__funcs.html#ga08779cba8c9adaf762b7680cff43d547">Cy_SysClk_PeriPclkEnableDivider</a>((1U &lt;&lt; PERI_PCLK_GR_NUM_Pos), <a class="code" href="group__group__sysclk__clk__peripheral__enums.html#gga06138349be16d91fd5d00ded2f4592b8ad2299deae6e36a070de5a60368b319ad">CY_SYSCLK_DIV_8_BIT</a>, 0U);</div></div><!-- fragment --><p> Group of two SAR2 ADC channels are configured, one for bandgap voltage and one for the AN0 analogue input:</p>
<div class="fragment"><div class="line"><span class="comment">/* Scenario: SAR2 ADC configuration */</span></div><div class="line"><a class="code" href="structcy__stc__sar2__channel__config__t.html">cy_stc_sar2_channel_config_t</a> channel_vbg_config =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__sar2__channel__config__t.html#af729622f4adf0f92a2a1f53301d3297b">channelHwEnable</a> = <span class="keyword">true</span>,</div><div class="line">    .triggerSelection = <a class="code" href="group__group__sar2__enums.html#ggaba3cfba41b39cb3b447d613b48229198ab102cc947b2422987beff93cd93b6e1a">CY_SAR2_TRIGGER_OFF</a>,</div><div class="line">    .channelPriority = 0U,</div><div class="line">    .preenptionType = <a class="code" href="group__group__sar2__enums.html#ggab8244721c05442758f3f1b61792e80c6a79a8c604659820c33e39bb5e877295b4">CY_SAR2_PREEMPTION_FINISH_RESUME</a>,</div><div class="line">    .isGroupEnd = <span class="keyword">false</span>,</div><div class="line">    .pinAddress = <a class="code" href="group__group__sar2__enums.html#ggaff7c2edefeb5747dbe17f065a27973e3aef10dbb2bf2c678eab0f823c874f2054">CY_SAR2_PIN_ADDRESS_VBG</a>,</div><div class="line">    .portAddress = <a class="code" href="group__group__sar2__enums.html#ggadfcc89e9de3212bd0eb47a9bc4d18e8faefebb4cc5690437cf08d1b143da41aa5">CY_SAR2_PORT_ADDRESS_SARMUX0</a>,</div><div class="line">    .extMuxEnable = <span class="keyword">true</span>,</div><div class="line">    .extMuxSelect = 0U,</div><div class="line">    .preconditionMode = <a class="code" href="group__group__sar2__enums.html#gga75f6f289e993b67ada3222e4394c378ba4336c541eae52db68665714ea09d1999">CY_SAR2_PRECONDITION_MODE_OFF</a>,</div><div class="line">    .overlapDiagMode = <a class="code" href="group__group__sar2__enums.html#gga481e014914f83c1d91387b4adb96fa07ad80b5136f3dfbf9340edb28dbd1ad2d3">CY_SAR2_OVERLAP_DIAG_MODE_OFF</a>,</div><div class="line">    .sampleTime = 120U,</div><div class="line">    .postProcessingMode = <a class="code" href="group__group__sar2__enums.html#ggaeb91f0e98ffd0ccf1fbc9ac4ee4d2ecfa3b0a64bbb1dd1aeeaaaaf3157c1c8eaa">CY_SAR2_POST_PROCESSING_MODE_NONE</a>,</div><div class="line">    .resultAlignment = <a class="code" href="group__group__sar2__enums.html#gga063234382f49c6003504631cdcc2c098a83feb25c8aedebb31abc5da43b6617ff">CY_SAR2_RESULT_ALIGNMENT_RIGHT</a>,</div><div class="line">    .signExtention = <a class="code" href="group__group__sar2__enums.html#ggab710a08c4f378212fccc7ef2388cd1fca39542cbc68a10be6ada97b4b7db52b30">CY_SAR2_SIGN_EXTENTION_UNSIGNED</a>,</div><div class="line">    .averageCount = 1U,</div><div class="line">    .rightShift = 0U,</div><div class="line">    .rangeDetectionMode = <a class="code" href="group__group__sar2__enums.html#gga835a6d564cab91f15a6cd1598b4fa792aee34dab51e8d0b5114ee6a09db965a5c">CY_SAR2_RANGE_DETECTION_MODE_INSIDE_RANGE</a>,</div><div class="line">    .rangeDetectionLoThreshold = 0U,</div><div class="line">    .rangeDetectionHiThreshold = 65535U,</div><div class="line">};</div><div class="line"></div><div class="line"><a class="code" href="structcy__stc__sar2__channel__config__t.html">cy_stc_sar2_channel_config_t</a> channel_an0_config =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__sar2__channel__config__t.html#af729622f4adf0f92a2a1f53301d3297b">channelHwEnable</a> = <span class="keyword">true</span>,</div><div class="line">    .triggerSelection = <a class="code" href="group__group__sar2__enums.html#ggaba3cfba41b39cb3b447d613b48229198ab102cc947b2422987beff93cd93b6e1a">CY_SAR2_TRIGGER_OFF</a>,</div><div class="line">    .channelPriority = 0U,</div><div class="line">    .preenptionType = <a class="code" href="group__group__sar2__enums.html#ggab8244721c05442758f3f1b61792e80c6a79a8c604659820c33e39bb5e877295b4">CY_SAR2_PREEMPTION_FINISH_RESUME</a>,</div><div class="line">    .isGroupEnd = <span class="keyword">true</span>,</div><div class="line">    .pinAddress = <a class="code" href="group__group__sar2__enums.html#ggaff7c2edefeb5747dbe17f065a27973e3a90d178dfcd8a5270e05ad892f92f0a4e">CY_SAR2_PIN_ADDRESS_AN0</a>,</div><div class="line">    .portAddress = <a class="code" href="group__group__sar2__enums.html#ggadfcc89e9de3212bd0eb47a9bc4d18e8faefebb4cc5690437cf08d1b143da41aa5">CY_SAR2_PORT_ADDRESS_SARMUX0</a>,</div><div class="line">    .extMuxEnable = <span class="keyword">true</span>,</div><div class="line">    .extMuxSelect = 0U,</div><div class="line">    .preconditionMode = <a class="code" href="group__group__sar2__enums.html#gga75f6f289e993b67ada3222e4394c378ba4336c541eae52db68665714ea09d1999">CY_SAR2_PRECONDITION_MODE_OFF</a>,</div><div class="line">    .overlapDiagMode = <a class="code" href="group__group__sar2__enums.html#gga481e014914f83c1d91387b4adb96fa07ad80b5136f3dfbf9340edb28dbd1ad2d3">CY_SAR2_OVERLAP_DIAG_MODE_OFF</a>,</div><div class="line">    .sampleTime = 120U,</div><div class="line">    .postProcessingMode = <a class="code" href="group__group__sar2__enums.html#ggaeb91f0e98ffd0ccf1fbc9ac4ee4d2ecfa3b0a64bbb1dd1aeeaaaaf3157c1c8eaa">CY_SAR2_POST_PROCESSING_MODE_NONE</a>,</div><div class="line">    .resultAlignment = <a class="code" href="group__group__sar2__enums.html#gga063234382f49c6003504631cdcc2c098a83feb25c8aedebb31abc5da43b6617ff">CY_SAR2_RESULT_ALIGNMENT_RIGHT</a>,</div><div class="line">    .signExtention = <a class="code" href="group__group__sar2__enums.html#ggab710a08c4f378212fccc7ef2388cd1fca39542cbc68a10be6ada97b4b7db52b30">CY_SAR2_SIGN_EXTENTION_UNSIGNED</a>,</div><div class="line">    .averageCount = 1U,</div><div class="line">    .rightShift = 0U,</div><div class="line">    .rangeDetectionMode = <a class="code" href="group__group__sar2__enums.html#gga835a6d564cab91f15a6cd1598b4fa792aee34dab51e8d0b5114ee6a09db965a5c">CY_SAR2_RANGE_DETECTION_MODE_INSIDE_RANGE</a>,</div><div class="line">    .rangeDetectionLoThreshold = 0U,</div><div class="line">    .rangeDetectionHiThreshold = 65535U,</div><div class="line">};</div><div class="line"></div><div class="line"><a class="code" href="structcy__stc__sar2__config__t.html">cy_stc_sar2_config_t</a> sar2_config =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__sar2__config__t.html#af1add305e8c6e28318f865f836f4dcc6">preconditionTime</a> = 0U,</div><div class="line">    .powerupTime = 0U,</div><div class="line">    .enableIdlePowerDown = <span class="keyword">false</span>,</div><div class="line">    .msbStretchMode = <a class="code" href="group__group__sar2__enums.html#gga56d872802c3c10aac99fb5f19856b8b2abc29a0eadcb1f3ccdffa6c6994539510">CY_SAR2_MSB_STRETCH_MODE_1CYCLE</a>,</div><div class="line">    .enableHalfLsbConv = <span class="keyword">false</span>,</div><div class="line">    .sarMuxEnable = <span class="keyword">true</span>,</div><div class="line">    .adcEnable = <span class="keyword">true</span>,</div><div class="line">    .sarIpEnable = <span class="keyword">true</span>,</div><div class="line">    .channelConfig = {&amp;channel_vbg_config, &amp;channel_an0_config,</div><div class="line">        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,</div><div class="line">        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, },</div><div class="line">};</div><div class="line"><span class="comment">/* We&#39;ve created group of two channels. By triggering the first one - whole group will be</span></div><div class="line"><span class="comment"> * executed. */</span></div></div><!-- fragment --> <h2><a class="anchor" id="group_sar2_init"></a>
Initialization</h2>
<div class="fragment"><div class="line">    <span class="comment">/* Scenario: SAR2 ADC initialization */</span></div><div class="line"><span class="preprocessor">    #define CH_VBG    (0u)</span></div><div class="line"><span class="preprocessor">    #define CH_AN0    (1u)</span></div><div class="line"></div><div class="line">    <span class="comment">/* Initialize the SAR2 module */</span></div><div class="line">    <a class="code" href="group__group__sar2__functions.html#gad6ddc69b82b06fda5952c5da00de35ed">Cy_SAR2_Init</a>(PASS0_SAR0, &amp;sar2_config);</div><div class="line"></div><div class="line">    <span class="comment">/* Set ePASS MMIO reference buffer mode for bangap voltage */</span></div><div class="line">    <a class="code" href="group__group__sar2__functions.html#gab2725bd7acf6658c561a1a4614c12c5d">Cy_SAR2_SetReferenceBufferMode</a>(PASS0_EPASS_MMIO, <a class="code" href="group__group__sar2__enums.html#ggae8a43f44bb634ee8c9d66a06e7b23a07af5e9cc0fc5bea961979bf5713eb715a8">CY_SAR2_REF_BUF_MODE_ON</a>);</div></div><!-- fragment --> <h2><a class="anchor" id="group_sar2_result"></a>
Obtaining results in counts</h2>
<div class="fragment"><div class="line">    <span class="comment">/* Scenario: Obtaining conversion results in counts */</span></div><div class="line">    uint16_t resultVBG;</div><div class="line">    uint16_t resultAN0;</div><div class="line"></div><div class="line">    <span class="comment">/* Issue software start trigger */</span></div><div class="line">    <a class="code" href="group__group__sar2__functions.html#ga07a7023e4f6db655204d25a21b036651">Cy_SAR2_Channel_SoftwareTrigger</a>(PASS0_SAR0, CH_VBG);</div><div class="line"></div><div class="line">    <span class="comment">/* Wait for conversion to finish */</span></div><div class="line">    <span class="keywordflow">while</span> (<a class="code" href="group__group__sar2__macros__interrupt.html#gaa882e6a45272a4e28a148f6c496372c8">CY_SAR2_INT_GRP_DONE</a> != <a class="code" href="group__group__sar2__functions.html#gae07d8e288f6863cef7e8fa37fa2c0f55">Cy_SAR2_Channel_GetInterruptStatus</a>(PASS0_SAR0, CH_AN0));</div><div class="line"></div><div class="line">    <span class="comment">/* Get conversion results in counts, do not obtain or analyze status here */</span></div><div class="line">    resultVBG = <a class="code" href="group__group__sar2__functions.html#ga6cf749ec06d3ab25ce139975f7baafcf">Cy_SAR2_Channel_GetResult</a>(PASS0_SAR0, CH_VBG, NULL);</div><div class="line">    resultAN0 = <a class="code" href="group__group__sar2__functions.html#ga6cf749ec06d3ab25ce139975f7baafcf">Cy_SAR2_Channel_GetResult</a>(PASS0_SAR0, CH_AN0, NULL);</div><div class="line">    <span class="comment">/* Each channel results are stored in ADC counts at this point. */</span></div><div class="line"></div><div class="line">    <span class="comment">/* Clear interrupt source */</span></div><div class="line">    <a class="code" href="group__group__sar2__functions.html#ga3038fbd14b4fef98a91a8713c559472d">Cy_SAR2_Channel_ClearInterrupt</a>(PASS0_SAR0, CH_AN0, <a class="code" href="group__group__sar2__macros__interrupt.html#gaa882e6a45272a4e28a148f6c496372c8">CY_SAR2_INT_GRP_DONE</a>);</div></div><!-- fragment --> <h2><a class="anchor" id="group_sar2_calc_volts"></a>
Calculating results in V, mV or uV</h2>
<div class="fragment"><div class="line">    <span class="comment">/* Scenario: Calculating V, mV and uV from counts. */</span></div><div class="line">    <a class="code" href="group__group__syslib__macros.html#ga4611b605e45ab401f02cab15c5e38715">float32_t</a> volts;</div><div class="line">    <a class="code" href="group__group__syslib__macros.html#ga4611b605e45ab401f02cab15c5e38715">float32_t</a> mVolts;</div><div class="line">    <a class="code" href="group__group__syslib__macros.html#ga4611b605e45ab401f02cab15c5e38715">float32_t</a> uVolts;</div><div class="line"></div><div class="line">    <span class="comment">/* Calculate conversion results in volts */</span></div><div class="line">    volts = (resultAN0 * 0.9f) / resultVBG;</div><div class="line">    mVolts = (resultAN0 * 900.0f) / resultVBG;</div><div class="line">    uVolts = (resultAN0 * 900000.0f) / resultVBG;</div></div><!-- fragment --> <h2><a class="anchor" id="group_sar2_die_temperature"></a>
Die temperature</h2>
<div class="fragment"><div class="line">    <span class="comment">/* Scenario: die temperature measurement */</span></div><div class="line">    uint16_t resultTemp;</div><div class="line">    <span class="keywordtype">double</span> dieTemperature;</div><div class="line">    <span class="comment">/* Reconfigure the CH_AN0 to measure the temperature sensor */</span></div><div class="line">    channel_an0_config.<a class="code" href="structcy__stc__sar2__channel__config__t.html#a4f6314e95c3a7779d57518e3ed5192af">pinAddress</a> = <a class="code" href="group__group__sar2__enums.html#ggaff7c2edefeb5747dbe17f065a27973e3ac7031bcefc8bd3752f19f965a813059a">CY_SAR2_PIN_ADDRESS_VTEMP</a>;</div><div class="line">    <span class="comment">/* Averaging is very useful for the temperature measurements */</span></div><div class="line">    channel_an0_config.<a class="code" href="structcy__stc__sar2__channel__config__t.html#a1313acc428a4c47f27c666636de0e9b8">averageCount</a> = 16U; <span class="comment">/* Accumulate 16 samples */</span></div><div class="line">    channel_an0_config.<a class="code" href="structcy__stc__sar2__channel__config__t.html#a780ea9a80b823d469396d1a352bf974d">rightShift</a> = 4U;    <span class="comment">/* Divide the result by 16 */</span></div><div class="line"></div><div class="line">    <span class="comment">/* Issue software start trigger */</span></div><div class="line">    <a class="code" href="group__group__sar2__functions.html#ga07a7023e4f6db655204d25a21b036651">Cy_SAR2_Channel_SoftwareTrigger</a>(PASS0_SAR0, CH_VBG);</div><div class="line"></div><div class="line">    <span class="comment">/* Wait for conversion to finish */</span></div><div class="line">    <span class="keywordflow">while</span> (<a class="code" href="group__group__sar2__macros__interrupt.html#gaa882e6a45272a4e28a148f6c496372c8">CY_SAR2_INT_GRP_DONE</a> != <a class="code" href="group__group__sar2__functions.html#gae07d8e288f6863cef7e8fa37fa2c0f55">Cy_SAR2_Channel_GetInterruptStatus</a>(PASS0_SAR0, CH_AN0));</div><div class="line"></div><div class="line">    <span class="comment">/* Get conversion results in counts, do not obtain or analyze status here */</span></div><div class="line">    resultVBG  = <a class="code" href="group__group__sar2__functions.html#ga6cf749ec06d3ab25ce139975f7baafcf">Cy_SAR2_Channel_GetResult</a>(PASS0_SAR0, CH_VBG, NULL); <span class="comment">/* Measure the VBG value */</span></div><div class="line">    resultTemp = <a class="code" href="group__group__sar2__functions.html#ga6cf749ec06d3ab25ce139975f7baafcf">Cy_SAR2_Channel_GetResult</a>(PASS0_SAR0, CH_AN0, NULL); <span class="comment">/* Measure the temperature sensor value */</span></div><div class="line"></div><div class="line">    <span class="comment">/* Assume the VDDA voltage is 3.3V */</span></div><div class="line">    dieTemperature = <a class="code" href="group__group__sar2__functions.html#gaf1153ebd358ba9773267508fbb787550">Cy_SAR2_CalculateDieTemperature</a>(<a class="code" href="group__group__sar2__enums.html#gga0b86fdbdcc9cf30993bd15a5e8bdb83baa44f86b0d697106946e818c4c88e17f8">CY_SAR2_VDDA_2_7V_TO_4_5V</a>, resultTemp, resultVBG);</div></div><!-- fragment --><p> Once done, in the variable, returned by the <a class="el" href="group__group__sar2__functions.html#gaf1153ebd358ba9773267508fbb787550">Cy_SAR2_CalculateDieTemperature</a> function will contain the die temperature value in Celsius degrees.</p>
<p>The accuracy can be increased by executing the calibration procedure (see <a class="el" href="group__group__sar2__calibration.html">Calibration procedure</a> section) before doing the conversion.</p>
<p>In the function call, the first argument is the enumeration value, representing the VDDA value range supplied to this particular chip being used, see <a class="el" href="group__group__sar2__enums.html#ga0b86fdbdcc9cf30993bd15a5e8bdb83b">cy_en_sar2_vdda_range_t</a>.</p>
<h2><a class="anchor" id="group_sar2_channel_grouping"></a>
Channel grouping</h2>
<p>The SAR2 driver supports the channel grouping. Each channel can be either in an individual group or in a group of 2 or more channels. By default, the hardware will execute the next channel if it exists and is in the Enabled state if the current channel does not have the flag 'Group End' set. You can set triggers to start either the first channel or any channel of the group to execute all the next channels.</p>
<h1><a class="anchor" id="group_sar2_more_information"></a>
More Information</h1>
<p>Refer to the technical reference manual (TRM) and the device datasheet.</p>
<h1><a class="anchor" id="group_sar2_changelog"></a>
Changelog</h1>
<table class="doxtable">
<tr>
<th>Version</th><th>Changes</th><th>Reason for Change </th></tr>
<tr>
<td>1.1 </td><td>Adding support for devices with up to 3 SAR slices. </td><td></td></tr>
<tr>
<td>1.0 </td><td>Initial version </td><td></td></tr>
</table>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="groups"></a>
API Reference</h2></td></tr>
<tr class="memitem:group__group__sar2__macro"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__sar2__macro.html">Macros</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__group__sar2__functions"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__sar2__functions.html">Functions</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__group__sar2__data__structures"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__sar2__data__structures.html">Data structures</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__group__sar2__enums"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__sar2__enums.html">Enumerated Types</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__group__sar2__calibration"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__sar2__calibration.html">Calibration procedure</a></td></tr>
<tr class="memdesc:group__group__sar2__calibration"><td class="mdescLeft">&#160;</td><td class="mdescRight"><br />
<br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>MTB CAT1 Peripheral driver library</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
